package org.dtrd.modules.record.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.dtrd.modules.control.entity.po.DtrdEntRdSigninTargetDetail;
import org.dtrd.modules.record.entity.bean.ValueUplowBean;
import org.dtrd.modules.record.entity.po.DtrdEntRdUplowRecord;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.Map;

/**
 * <p>
 * 血糖上下限 服务类
 * </p>
 *
 * @author QR
 * @since 2021-10-20
 */
public interface IDtrdEntRdUplowRecordService extends IService<DtrdEntRdUplowRecord> {

    /**
     * 通过 doctorId 获取对应 patientId 患者的血糖值上下限
     */
    ValueUplowBean getSugarValueUpLowRecord(Integer doctorId, Integer patientId);

    /**
     * 获取患者每天的血糖达标率
     */
    Map<Date, Integer> getSugarReachStandard(Integer patientId, Date startDate, Date endDate);

    /**
     * 获取患者周期内打卡计划的达标率
     * @param patientId
     * @param startDate
     * @param endDate
     * @return
     */
    Map<Date, Integer> getPeriodControllerTargetsReachRate(Integer patientId, Date startDate, Date endDate, Map<Integer, DtrdEntRdSigninTargetDetail> targetDetails);

    /**
     * 获取患者指定范围内的血糖达标平均率
     */
    Integer getSugarReachStandardAvgRateByRange(Integer patientId, Date startDate, Date endDate);

    /**
     * 获取患者本周的血糖达标平均率
     */
    Integer getSugarReachStandardRateThisWeek(Integer patientId);

    /**
     * 通过 patientId 获取上下限值
     */
    ValueUplowBean getSugarValueUpLowRecord(Integer patientId);

    @Transactional(rollbackFor = Exception.class)
    boolean saveOrUpdateUplowRecord(ValueUplowBean sugarValueUplow);

    float[] getSystolicPressure(Integer patientId);

    float[] getDiastolicPressure(Integer patientId);
}
